.class public Lcom/bitauto/autoeasy/widget/MyViewGroup;
.super Landroid/view/ViewGroup;
.source "MyViewGroup.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;
    }
.end annotation


# static fields
.field private static final TAG:Ljava/lang/String; = "MyViewGroup"


# instance fields
.field private context:Landroid/content/Context;

.field private currentScreenIndex:I

.field private fling:Z

.field private gestureDetector:Landroid/view/GestureDetector;

.field private newsList:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/bitauto/autoeasy/news/Object/News;",
            ">;"
        }
    .end annotation
.end field

.field private scrollToScreenCallback:Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;

.field private scroller:Landroid/widget/Scroller;

.field private textView:Landroid/widget/TextView;

.field private touching:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 77
    invoke-direct {p0, p1}, Landroid/view/ViewGroup;-><init>(Landroid/content/Context;)V

    .line 78
    invoke-direct {p0, p1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->initView(Landroid/content/Context;)V

    .line 79
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 0
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 72
    invoke-direct {p0, p1, p2}, Landroid/view/ViewGroup;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 73
    invoke-direct {p0, p1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->initView(Landroid/content/Context;)V

    .line 74
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 0
    .parameter "context"
    .parameter "attrs"
    .parameter "defStyle"

    .prologue
    .line 67
    invoke-direct {p0, p1, p2, p3}, Landroid/view/ViewGroup;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 68
    invoke-direct {p0, p1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->initView(Landroid/content/Context;)V

    .line 69
    return-void
.end method

.method static synthetic access$0(Lcom/bitauto/autoeasy/widget/MyViewGroup;)I
    .locals 1
    .parameter

    .prologue
    .line 40
    iget v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    return v0
.end method

.method static synthetic access$1(Lcom/bitauto/autoeasy/widget/MyViewGroup;Z)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 62
    iput-boolean p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->fling:Z

    return-void
.end method

.method private initView(Landroid/content/Context;)V
    .locals 2
    .parameter "context"

    .prologue
    .line 82
    new-instance v0, Landroid/widget/Scroller;

    invoke-direct {v0, p1}, Landroid/widget/Scroller;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scroller:Landroid/widget/Scroller;

    .line 84
    new-instance v0, Landroid/view/GestureDetector;

    new-instance v1, Lcom/bitauto/autoeasy/widget/MyViewGroup$1;

    invoke-direct {v1, p0, p1}, Lcom/bitauto/autoeasy/widget/MyViewGroup$1;-><init>(Lcom/bitauto/autoeasy/widget/MyViewGroup;Landroid/content/Context;)V

    invoke-direct {v0, v1}, Landroid/view/GestureDetector;-><init>(Landroid/view/GestureDetector$OnGestureListener;)V

    iput-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->gestureDetector:Landroid/view/GestureDetector;

    .line 132
    return-void
.end method

.method private snapToDestination()V
    .locals 2

    .prologue
    .line 228
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getScrollX()I

    move-result v0

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v1

    div-int/lit8 v1, v1, 0x2

    add-int/2addr v0, v1

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v1

    div-int/2addr v0, v1

    invoke-virtual {p0, v0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scrollToScreen(I)V

    .line 229
    return-void
.end method


# virtual methods
.method public JumpToNewS(Landroid/content/Context;)V
    .locals 4
    .parameter "context"

    .prologue
    .line 190
    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->newsList:Ljava/util/ArrayList;

    iget v3, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    invoke-virtual {v2, v3}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/bitauto/autoeasy/news/Object/News;

    .line 191
    .local v1, news:Lcom/bitauto/autoeasy/news/Object/News;
    new-instance v0, Landroid/content/Intent;

    const-class v2, Lcom/bitauto/autoeasy/news/NewsDetailActivity;

    invoke-direct {v0, p1, v2}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 192
    .local v0, intent:Landroid/content/Intent;
    const-string v2, "title"

    const-string v3, "\u6700\u65b0"

    invoke-virtual {v0, v2, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 193
    const-string v2, "newsid"

    invoke-virtual {v1}, Lcom/bitauto/autoeasy/news/Object/News;->getNewsid()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v0, v2, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 194
    invoke-virtual {p1, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    .line 195
    return-void
.end method

.method public computeScroll()V
    .locals 2

    .prologue
    .line 154
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scroller:Landroid/widget/Scroller;

    invoke-virtual {v0}, Landroid/widget/Scroller;->computeScrollOffset()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 155
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scroller:Landroid/widget/Scroller;

    invoke-virtual {v0}, Landroid/widget/Scroller;->getCurrX()I

    move-result v0

    const/4 v1, 0x0

    invoke-virtual {p0, v0, v1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scrollTo(II)V

    .line 156
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->postInvalidate()V

    .line 158
    :cond_0
    return-void
.end method

.method protected onLayout(ZIIII)V
    .locals 6
    .parameter "changed"
    .parameter "left"
    .parameter "top"
    .parameter "right"
    .parameter "bottom"

    .prologue
    const/4 v5, 0x0

    .line 137
    const-string v2, "MyViewGroup"

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, ">>left: "

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, " top: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, " right: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    .line 138
    const-string v4, " bottom:"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    .line 137
    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 143
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getChildCount()I

    move-result v2

    if-lt v1, v2, :cond_0

    .line 150
    return-void

    .line 144
    :cond_0
    invoke-virtual {p0, v1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getChildAt(I)Landroid/view/View;

    move-result-object v0

    .line 145
    .local v0, child:Landroid/view/View;
    invoke-virtual {v0, v5}, Landroid/view/View;->setVisibility(I)V

    .line 146
    sub-int v2, p4, p2

    sub-int v3, p5, p3

    invoke-virtual {v0, v2, v3}, Landroid/view/View;->measure(II)V

    .line 147
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v2

    mul-int/2addr v2, v1

    add-int/lit8 v2, v2, 0x0

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v3

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v4

    mul-int/2addr v4, v1

    add-int/2addr v3, v4

    .line 148
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getHeight()I

    move-result v4

    .line 147
    invoke-virtual {v0, v2, v5, v3, v4}, Landroid/view/View;->layout(IIII)V

    .line 143
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .locals 3
    .parameter "event"

    .prologue
    const/4 v2, 0x1

    const/4 v1, 0x0

    .line 162
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->gestureDetector:Landroid/view/GestureDetector;

    invoke-virtual {v0, p1}, Landroid/view/GestureDetector;->onTouchEvent(Landroid/view/MotionEvent;)Z

    .line 164
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    packed-switch v0, :pswitch_data_0

    .line 183
    :goto_0
    return v2

    .line 166
    :pswitch_0
    iput-boolean v2, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->touching:Z

    goto :goto_0

    .line 169
    :pswitch_1
    iput-boolean v1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->touching:Z

    goto :goto_0

    .line 172
    :pswitch_2
    iget-boolean v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->touching:Z

    if-eqz v0, :cond_0

    .line 173
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->context:Landroid/content/Context;

    invoke-virtual {p0, v0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->JumpToNewS(Landroid/content/Context;)V

    .line 175
    :cond_0
    iget-boolean v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->fling:Z

    if-nez v0, :cond_1

    .line 176
    invoke-direct {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->snapToDestination()V

    .line 178
    :cond_1
    iput-boolean v1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->fling:Z

    goto :goto_0

    .line 164
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_2
        :pswitch_1
    .end packed-switch
.end method

.method public scrollToScreen(I)V
    .locals 6
    .parameter "whichScreen"

    .prologue
    const/4 v2, 0x0

    .line 204
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getFocusedChild()Landroid/view/View;

    move-result-object v0

    if-eqz v0, :cond_0

    iget v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    if-eq p1, v0, :cond_0

    .line 205
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getFocusedChild()Landroid/view/View;

    move-result-object v0

    iget v1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    invoke-virtual {p0, v1}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getChildAt(I)Landroid/view/View;

    move-result-object v1

    if-ne v0, v1, :cond_0

    .line 206
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getFocusedChild()Landroid/view/View;

    move-result-object v0

    invoke-virtual {v0}, Landroid/view/View;->clearFocus()V

    .line 209
    :cond_0
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getWidth()I

    move-result v0

    mul-int/2addr v0, p1

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getScrollX()I

    move-result v1

    sub-int v3, v0, v1

    .line 210
    .local v3, delta:I
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scroller:Landroid/widget/Scroller;

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->getScrollX()I

    move-result v1

    invoke-static {v3}, Ljava/lang/Math;->abs(I)I

    move-result v4

    mul-int/lit8 v5, v4, 0x2

    move v4, v2

    invoke-virtual/range {v0 .. v5}, Landroid/widget/Scroller;->startScroll(IIIII)V

    .line 211
    invoke-virtual {p0}, Lcom/bitauto/autoeasy/widget/MyViewGroup;->invalidate()V

    .line 213
    iput p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    .line 214
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scrollToScreenCallback:Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;

    if-eqz v0, :cond_1

    .line 215
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scrollToScreenCallback:Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;

    .line 216
    iget v1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    invoke-interface {v0, v1}, Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;->callback(I)V

    .line 220
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->textView:Landroid/widget/TextView;

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->newsList:Ljava/util/ArrayList;

    iget v2, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->currentScreenIndex:I

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, Lcom/bitauto/autoeasy/news/Object/News;

    invoke-virtual {p0}, Lcom/bitauto/autoeasy/news/Object/News;->getTitle()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 222
    :cond_1
    return-void
.end method

.method public setContext(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 31
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->context:Landroid/content/Context;

    .line 32
    return-void
.end method

.method public setList(Ljava/util/ArrayList;)V
    .locals 0
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/bitauto/autoeasy/news/Object/News;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 53
    .local p1, newsList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/bitauto/autoeasy/news/Object/News;>;"
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->newsList:Ljava/util/ArrayList;

    .line 54
    return-void
.end method

.method public setScrollToScreenCallback(Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;)V
    .locals 0
    .parameter "scrollToScreenCallback"

    .prologue
    .line 58
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->scrollToScreenCallback:Lcom/bitauto/autoeasy/widget/MyViewGroup$ScrollToScreenCallback;

    .line 59
    return-void
.end method

.method public setTextView(Landroid/widget/TextView;)V
    .locals 0
    .parameter "textView"

    .prologue
    .line 49
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/MyViewGroup;->textView:Landroid/widget/TextView;

    .line 50
    return-void
.end method
